clear
set more off
set seed 394
clear matrix
clear mata
set matsize 11000
set maxvar 30000
set linesize 255
ssc install boottest

* directory name here
local dir ""

cd "`dir'"

use data_main, clear


* list of county-level control variables
local controls "pop female urban popsq white age21pct sch12 log_manu"

** alternative controls **
* constant controls (1944)
foreach x of local controls {
	gen tmp`x'=`x' if year==1944
	bysort fipscode: egen `x'f=total(tmp`x')
	replace `x'f=. if `x'==.
	drop tmp`x'
}

quietly tab year, gen(yeard)

local vars "popf femalef urbanf popsqf whitef age21pctf sch12f log_manuf"

foreach x of local vars {
	forvalues i=1(1)2 {
		egen m`i'=mean(`x') if s`i'==1
		gen `x'`i'=`x'-m`i' if s`i'==1
		replace `x'`i'=`x'`i'*tv
		drop m`i'
	}
}

* alternative controls
local controls1 "popf1 femalef1 urbanf1 popsqf1 whitef1 age21pctf1 sch12f1 log_manuf1"
local controls2 "popf2 femalef2 urbanf2 popsqf2 whitef2 age21pctf2 sch12f2 log_manuf2"


*****************
* Main Analyses *
*****************

** Table 2 **

compress
eststo clear
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls'            if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls'            if s2==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls' countydum* if s2==1, a(fipscode year) cluster(fipscode)

eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls'            if s1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls'            if s1==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls' countydum* if s1==1, a(fipscode year) cluster(fipscode)

local table_name  "table_main"
local table_label "econ"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us) ///
order (tv tvXincome_d1_us tvXunemp_d1_us)


quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections}"
	noisily display "\label{`table_label'}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County& County& County& County\\"
    noisily display "& Year& State-Year & Year& Year& State-Year   & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{National Unemployment}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

** Table 3 **

eststo clear
eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' 		     if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv           tvXincome_d1_us tvXincome_d1 `controls' 	  	     if s2==1, a(fipscode sy)   cluster(fipscode)
eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' countydum* if s2==1, a(fipscode year) cluster(fipscode)

local table_name  "table_state"
local table_label "econst"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv income_d1 tvXincome_d1 income_d1_us tvXincome_d1_us) ///
order (tv income_d1 tvXincome_d1 income_d1_us tvXincome_d1_us)



quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and State Level Economic Voting and TV in Presidential Elections}"
	noisily display "\label{econst}"
	noisily display "\begin{tabular}{lccc}"
	noisily display "\midrule\midrule"
	noisily display "\multicolumn{4}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\midrule"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County \\"
    noisily display "& Year& State-Year&  Year \\"
	noisily display "County Trends & No& No&  Yes \\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{State Income}$ are standardized."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}


*********************
** Online Appendix ** 
*********************

** without controls **

compress
eststo clear
eststo: quietly reghdfe vd_p tv tvXincome_d1_us                    if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us                    if s2==1, a(fipscode sy)   cluster(fipscode)
eststo: quietly areg    vd_p tv tvXincome_d1_us countydum*  i.year if s2==1, a(fipscode)      cluster(fipscode)

eststo: quietly reghdfe vd_p tv tvXunemp_d1_us                   if s1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us                   if s1==1, a(fipscode sy)   cluster(fipscode)
eststo: quietly areg    vd_p tv tvXunemp_d1_us countydum* i.year if s1==1, a(fipscode)      cluster(fipscode)

local table_name  "table_main_wocon"
local table_label "econ_wocon"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us) ///
order (tv tvXincome_d1_us tvXunemp_d1_us)

quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections (without Controls)}"
	noisily display "\label{`table_label'}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County& County& County& County\\"
    noisily display "& Year& State-Year & Year& Year& State-Year   & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econ}."
	noisily display "All the models in the table do not contain any county-level control variable."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{National Unemployment}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}



** alternative dependent variable **

* recode independent variables
foreach x in income_d1_us unemp_d1_us income_d1 {
	replace `x' = `x' * inc_pres_p
	replace tvX`x' = tv * `x'
}

* main results 

compress
eststo clear
eststo: quietly reghdfe vip_p tv tvXincome_d1_us `controls'            if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vip_p tv tvXincome_d1_us `controls'            if s2==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vip_p tv tvXincome_d1_us `controls' countydum* if s2==1, a(fipscode year) cluster(fipscode)

eststo: quietly reghdfe vip_p tv tvXunemp_d1_us `controls'             if s1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vip_p tv tvXunemp_d1_us `controls'             if s1==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vip_p tv tvXunemp_d1_us `controls'  countydum* if s1==1, a(fipscode year) cluster(fipscode)

local table_name  "table_main_inc"
local table_label "econ_inc"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us) ///
order (tv tvXincome_d1_us tvXunemp_d1_us)


quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections (Alternative Dependent Variable)}"
	noisily display "\label{`table_label'}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Incumbent Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County& County& County& County\\"
    noisily display "& Year& State-Year & Year& Year& State-Year   & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econ} using the incumbent vote share as"
	noisily display "the dependent variable."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{National Unemployment}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

* with state economy 

eststo clear
eststo: quietly reghdfe vip_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls'		      if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vip_p tv           tvXincome_d1_us tvXincome_d1 `controls'      	  if s2==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vip_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' countydum* if s2==1, a(fipscode year) cluster(fipscode)

local table_name  "table_state_inc"
local table_label "econst_inc"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv income_d1 tvXincome_d1 tvXincome_d1_us) ///
order (tv income_d1 tvXincome_d1 tvXincome_d1_us)



quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and State Level Economic Voting and TV in Presidential Elections (Alternative Dependent Variable)}"
	noisily display "\label{econst}"
	noisily display "\begin{tabular}{lccc}"
	noisily display "\midrule\midrule"
	noisily display "\multicolumn{4}{c}{Dependent Var = Incumbent Vote Share}\\"
	noisily display "\midrule"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County \\"
    noisily display "& Year& State-Year&  Year \\"
	noisily display "County Trends & No& No&  Yes \\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econst} using the incumbent vote share as"
	noisily display "the dependent variable."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{State Income}$ are standardized."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

* back to original coding
foreach x in income_d1_us unemp_d1_us income_d1 {
	replace `x' = `x' * inc_pres_p
	replace tvX`x' = tv * `x'
}


** alternative control variables **

* main results

compress
eststo clear
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls2'             if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls2'             if s2==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls2'  countydum* if s2==1, a(fipscode year) cluster(fipscode)

eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls1'            if s1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls1'            if s1==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls1' countydum* if s1==1, a(fipscode year) cluster(fipscode)

local table_name  "table_main_cont"
local table_label "econ_cont"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us) ///
order (tv tvXincome_d1_us tvXunemp_d1_us)


quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections, Alternative Control Variables}"
	noisily display "\label{econ_cont}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects &  County& County& County& County& County& County\\"
    noisily display "& Year& State-Year & Year& Year& State-Year   & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econ} using \$TV \times$ pre-treatment control variables"
	noisily display "fixed at the 1944 level."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{National Unemployment}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

* with state economy

eststo clear
eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls2' 		      if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv           tvXincome_d1_us tvXincome_d1 `controls2'  	      if s2==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls2' countydum* if s2==1, a(fipscode year) cluster(fipscode)

local table_name  "table_state_cont"
local table_label "econst_cont"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv income_d1 tvXincome_d1 tvXincome_d1_us) ///
order (tv income_d1 tvXincome_d1 tvXincome_d1_us)



quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and State Level Economic Voting and TV in Presidential Elections}"
	noisily display "\label{econst_cont}"
	noisily display "\begin{tabular}{lccc}"
	noisily display "\midrule\midrule"
	noisily display "\multicolumn{4}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\midrule"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County \\"
    noisily display "& Year& State-Year&  Year \\"
	noisily display "County Trends & No& No&  Yes \\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econst} using \$TV \times$ pre-treatment control variables"
	noisily display "fixed at the 1944 level."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{State Income}$ are standardized."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}


** drop one election at a time **

forvalues m = 1/3 {
	if `m' == 1 {
		local spec "`controls' if s2==1, a(fipscode year) cluster(fipscode)"
	}
	else if `m' == 2 {
		local spec "`controls' if s2==1, a(fipscode sy) cluster(fipscode)"
	}
	else if `m' == 3 {
		local spec "`controls' countydum* if s2==1, a(fipscode year) cluster(fipscode)"
	}	
	forvalues i = 1948(4)1964 {
		preserve
		drop if year == `i'
		foreach y in income unemp {
			quietly reghdfe vd_p tv tvX`y'_d1_us `spec'
			local beta_`y'`i'_m`m' = _b[tvX`y'_d1_us]
			local se_`y'`i'_m`m' = _se[tvX`y'_d1_us]
			local obs_`y'`i' = e(N)

			local p_`y'`i' = 2 * normal(-abs( `beta_`y'`i'_m`m'' / `se_`y'`i'_m`m''))
			if `p_`y'`i'' < 0.01 {
				local sig_`y'`i'_m`m' = "\sym{***}"
			}
			else if `p_`y'`i'' < 0.05 {
				local sig_`y'`i'_m`m' = "\sym{**}"
			}
			else if `p_`y'`i'' < 0.1 {
				local sig_`y'`i'_m`m' = "\sym{*}"
			}
			else {
				local sig_`y'`i'_m`m' = ""
			}
		}
		restore
	}
	
	if `m' == 1 {
		local reg "reghdfe vd_p tv tvXincome_d1_us `controls' if s2==1 & year != 1944, a(fipscode year) cluster(fipscode)"
	}
	else if `m' == 2 {
		local reg "reghdfe vd_p tv tvXincome_d1_us `controls' if s2==1 & year != 1944, a(fipscode sy) cluster(fipscode)"
	}
	else if `m' == 3 {
		local reg "reghdfe vd_p tv tvXincome_d1_us `controls' countydum* if s2==1 & year != 1944, a(fipscode year) cluster(fipscode)"
	}	
	quietly `reg'
	local beta1944_m`m' = _b[tvXincome_d1_us]
	local se1944_m`m' = _se[tvXincome_d1_us]
	local obs1944 = e(N)
	local p1944 = 2 * normal(-abs( `beta1944' / `se1944'))
	if `p1944' < 0.01 {
		local sig1944_m`m' = "\sym{***}"
	}
	else if `p1944' < 0.05 {
		local sig1944_m`m' = "\sym{**}"
	}
	else if `p1944' < 0.1 {
		local sig1944_m`m' = "\sym{*}"
	}
	else {
		local sig1944_m`m' = ""
	}
}

local table_name  "table_drop"
local table_label "econ_drop"

quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections: Dropping One Election at a Time}"
	noisily display "\label{`table_label'}"
	noisily display "\begin{tabular}{ccccccccc}"
	noisily display "\midrule\midrule"
	noisily display _asis "&\multicolumn{4}{c}{TV $\times \Delta$ Nat. Income}&\multicolumn{4}{c}{TV $\times \Delta$ Nat. Unemployment}\\"
	noisily display "\cmidrule(r){2-5}\cmidrule(r){6-9}"
	noisily display "Years Excluded &\multicolumn{3}{c}{Coefficient}&Obs.&\multicolumn{3}{c}{Coefficient}&Obs.\\ "
	noisily display "\cmidrule(r){1-1}\cmidrule(r){2-4}\cmidrule(r){5-5}\cmidrule(r){6-8}\cmidrule(r){9-9}"
	
	noisily display _asis "\multirow{2}{*}{1944}"
	forvalues m = 1/3 {
		noisily display _asis "&"  %5.3f `beta1944_m`m''  "`sig1944_m`m''"
	}
	noisily display _asis "&\multirow{2}{*}{" %6.0fc `obs1944' "}"
	noisily display "&&&&\\"
	forvalues m = 1/3 {
		noisily display _asis "&("  %5.3f `se1944_m`m''  ")"
	}	
	noisily display "&&&&\\"
	
	noisily display "\addlinespace"	
	forvalues i = 1948(4)1964 {
		noisily display _asis "\multirow{2}{*}{`i'}"
		foreach y in income unemp {
			forvalues m = 1/3 {
				noisily display _asis "&"  %5.3f `beta_`y'`i'_m`m''  "`sig_`y'`i'_m`m''"
			}
		noisily display _asis "&\multirow{2}{*}{" %6.0fc `obs_`y'`i'' "}"
		}
		noisily display "\\"
		foreach y in income unemp {
			forvalues m = 1/3 {
				noisily display _asis "&("  %5.3f `se_`y'`i'_m`m''  ")"
			}
		noisily display "&"
		}
		noisily display "\\"
		noisily display "\addlinespace"	
	}
	noisily display "\midrule"
	noisily display "Fixed Effects & County& County& County& & County& County & County\\"
    noisily display "& Year& State-Year & Year& & Year& State-Year & Year\\"
	noisily display "County Trends & No& No& Yes& &  No& No& Yes\\"	
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econ} after dropping each year one at a time."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."	
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
	

	log off
  
	log close
}


** matched sample **

* main results

eststo clear
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls'             if s2==1 & match1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls'             if s2==1 & match1==1, a(fipscode sy)   cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us `controls'  countydum* if s2==1 & match1==1, a(fipscode year) cluster(fipscode)

eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls'             if s1==1 & match1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls'             if s1==1 & match1==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us `controls'  countydum* if s1==1 & match1==1, a(fipscode year) cluster(fipscode)

local table_name  "table_main_m"
local table_label "econ_m"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us) ///
order (tv tvXincome_d1_us tvXunemp_d1_us)

quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections, Matched Sample}"
	noisily display "\label{econ_m}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County& County& County& County\\"
    noisily display "& Year& State-Year & Year& Year& State-Year & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econ} using matched sample."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{National Unemployment}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

* with state economy

eststo clear

eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' 		     if s2==1 & match1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv           tvXincome_d1_us tvXincome_d1 `controls'  		     if s2==1 & match1==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' countydum* if s2==1 & match1==1, a(fipscode year) cluster(fipscode)

local table_name  "table_state_m"
local table_label "econst_m"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv income_d1 tvXincome_d1 tvXincome_d1_us) ///
order (tv income_d1 tvXincome_d1 tvXincome_d1_us)



quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and State Level Economic Voting and TV in Presidential Elections (Matched Sample)}"
	noisily display "\label{econst_m}"
	noisily display "\begin{tabular}{lccc}"
	noisily display "\midrule\midrule"
	noisily display "\multicolumn{4}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\midrule"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County\\"
    noisily display "&Year& State-Year & Year\\"
	noisily display "County Trends & No& No& Yes \\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Table \ref{econst} using matched sample."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{State Income}$ are standardized."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}


** paired sample **

eststo clear
eststo: quietly reghdfe vd_p tv           tvXincome_d1_us              `controls' if s2==1 & pair==1, a(fipscode year) cluster(pair_id)
eststo: quietly reghdfe vd_p tv           tvXunemp_d1_us               `controls' if s1==1 & pair==1, a(fipscode year) cluster(pair_id)
eststo: quietly reghdfe vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' if s2==1 & pair==1, a(fipscode year) cluster(pair_id)

local table_name  "table_paired"
local table_label "econ_p"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us income_d1 tvXincome_d1) ///
order (tv tvXincome_d1_us tvXunemp_d1_us income_d1 tvXincome_d1)

quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and State Level Economic Voting and TV in Presidential Elections (Paired Sample)}"
	noisily display "\label{econst_p}"
	noisily display "\begin{tabular}{lccc}"
	noisily display "\midrule\midrule"
	noisily display "\multicolumn{4}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\midrule"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects   &  County&         County&         County\\"
    noisily display "  &       Year&   Year      &         Year\\"
	
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item This table replicates Tables \ref{econ} and \ref{econst} using paired sample."
	noisily display "Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$, \$\Delta \text{National Unemployment}$, and \$\Delta \text{State Income}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

** two-way clustering **

* main results

label var tvXincome_d1_us "TV $\times$ $\Delta$ National Income ($\beta$)"
label var tvXunemp_d1_us    "TV $\times$ $\Delta$ National Unemployment ($\beta$)"

compress
eststo clear
eststo est1: quietly areg vd_p tv income_d1_us tvXincome_d1_us `controls' i.year if s2==1, a(fipscode) cluster(fipscode)
quietly boottest tvXincome_d1_us, clust(fipscode year) bootcluster(year) nograph
local t1 = r(t)
local p1 = r(p)
eststo est2: quietly areg vd_p tv tvXincome_d1_us `controls' i.sy              if s2==1, a(fipscode) cluster(fipscode)
quietly boottest tvXincome_d1_us, clust(fipscode year) bootcluster(year) nograph
local t2 = r(t)
local p2 = r(p)
eststo est3: quietly areg vd_p tv tvXincome_d1_us `controls' i.year countydum* if s2==1, a(fipscode) cluster(fipscode)
quietly boottest tvXincome_d1_us, clust(fipscode year) bootcluster(year) nograph
local t3 = r(t)
local p3 = r(p)

eststo est4: quietly areg vd_p tv tvXunemp_d1_us `controls' i.year            if s1==1, a(fipscode) cluster(fipscode)
quietly boottest tvXunemp_d1_us, clust(fipscode year) bootcluster(year) nograph
local t4 = r(t)
local p4 = r(p)
eststo est5: quietly areg vd_p tv tvXunemp_d1_us `controls' i.sy              if s1==1, a(fipscode) cluster(fipscode)
quietly boottest tvXunemp_d1_us, clust(fipscode year) bootcluster(year) nograph
local t5 = r(t)
local p5 = r(p)
eststo est6: quietly areg vd_p tv tvXunemp_d1_us `controls' i.year countydum* if s1==1, a(fipscode) cluster(fipscode)
quietly boottest tvXunemp_d1_us, clust(fipscode year) bootcluster(year) nograph
local t6 = r(t)
local p6 = r(p)

forvalues i = 1/6 {
	if `p`i'' < 0.01 {
		local sig`i' = "\sym{***}"
	}
	else if `p`i'' < 0.05 {
		local sig`i' = "\sym{**}"
	}
	else if `p`i'' < 0.1 {
		local sig`i' = "\sym{*}"
	}
	else {
		local sig`i' = ""
	}
}

local table_name  "table_main_tw"
local table_label "econ_tw"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f) noobs ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us) ///
order (tv tvXincome_d1_us tvXunemp_d1_us)


quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Economic Voting and TV in Presidential Elections (Two-Way Clustering)}"
	noisily display "\label{`table_label'}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	
	noisily display _asis "\textit{t}-statistic from" 
	forvalues i = 1/6 {
		noisily display _asis "&\multirow{2}{*}{" %5.3f `t`i'' "`sig`i''}"
	}
	noisily display "\\"
	noisily display "Wild Bootstrap ($\beta = 0$)&&&&&&\\"
	noisily display "\midrule"

	noisily display "N"
	forvalues i = 1/6 {
		estimates restore est`i'
		local obs = e(N)
		noisily display "&" %6.0fc `obs'
	}
	
	noisily display "\\"		
	noisily display "Fixed Effects & County& County& County& County& County& County\\"
    noisily display "&Year & State-Year& Year & Year& State-Year & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item Standard errors are calculated using two-way clustering by county and year."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{National Unemployment}$ are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "t-statistic from a wild bootstrap test is calculated"
	noisily display "according to Roodman et al. (2019)."	
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}


* with state economy

label var tvXincome_d1_us "TV $\times$ $\Delta$ National Income ($\beta$)"
label var tvXunemp_d1_us    "TV $\times$ $\Delta$ National Unemployment ($\beta$)"

compress
eststo clear
eststo est1: quietly areg vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' i.year		      if s2==1, a(fipscode) cluster(fipscode)
quietly boottest tvXincome_d1_us, clust(fipscode year) bootcluster(year) nograph
local t1 = r(t)
local p1 = r(p)
eststo est2: quietly areg vd_p tv tvXincome_d1_us tvXincome_d1 `controls' i.sy		      if s2==1, a(fipscode) cluster(fipscode)
quietly boottest tvXincome_d1_us, clust(fipscode year) bootcluster(year) nograph
local t2 = r(t)
local p2 = r(p)
eststo est3: quietly areg vd_p tv income_d1 tvXincome_d1_us tvXincome_d1 `controls' i.year countydum* if s2==1, a(fipscode) cluster(fipscode)
quietly boottest tvXincome_d1_us, clust(fipscode year) bootcluster(year) nograph
local t3 = r(t)
local p3 = r(p)

forvalues i = 1/3 {
	if `p`i'' < 0.01 {
		local sig`i' = "\sym{***}"
	}
	else if `p`i'' < 0.05 {
		local sig`i' = "\sym{**}"
	}
	else if `p`i'' < 0.1 {
		local sig`i' = "\sym{*}"
	}
	else {
		local sig`i' = ""
	}
}

local table_name  "table_state_tw"
local table_label "econst_tw"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv income_d1 tvXincome_d1 tvXincome_d1_us) ///
order (tv income_d1 tvXincome_d1 tvXincome_d1_us)



quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and State Level Economic Voting and TV in Presidential Elections (Two-Way Clustering)}"
	noisily display "\label{econst_tw}"
	noisily display "\begin{tabular}{lccc}"
	noisily display "\midrule\midrule"
	noisily display "\multicolumn{4}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\midrule"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display _asis "\textit{t}-statistic from" 
	forvalues i = 1/3 {
		noisily display _asis "&\multirow{2}{*}{" %5.3f `t`i'' "`sig`i''}"
	}
	noisily display "\\"
	noisily display "Wild Bootstrap ($\beta = 0$)&&&\\"
	noisily display "\midrule"

	noisily display "N"
	forvalues i = 1/3 {
		estimates restore est`i'
		local obs = e(N)
		noisily display "&" %6.0fc `obs'
	}
	
	noisily display "\\"		
	noisily display "Fixed Effects & County& County& County \\"
    noisily display "& Year& State-Year&  Year \\"
	noisily display "County Trends & No& No&  Yes \\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$ and \$\Delta \text{State Income}$ are standardized."
	noisily display "t-statistic from a wild bootstrap test is calculated"
	noisily display "according to Roodman et al. (2019)."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}

** with local economic indicator **

local controls "pop female urban popsq white age21pct sch12"


compress
eststo clear
eststo: quietly reghdfe vd_p tv tvXincome_d1_us log_manu tvXlog_manu `controls'            if s2==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us log_manu tvXlog_manu `controls'            if s2==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXincome_d1_us log_manu tvXlog_manu `controls' countydum* if s2==1, a(fipscode year) cluster(fipscode)

eststo: quietly reghdfe vd_p tv tvXunemp_d1_us log_manu tvXlog_manu  `controls'             if s1==1, a(fipscode year) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us log_manu tvXlog_manu  `controls'             if s1==1, a(fipscode sy) cluster(fipscode)
eststo: quietly reghdfe vd_p tv tvXunemp_d1_us log_manu tvXlog_manu  `controls'  countydum* if s1==1, a(fipscode year) cluster(fipscode)

local table_name  "table_local"
local table_label "econ_local"

esttab using "`table_name'_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv tvXincome_d1_us tvXunemp_d1_us log_manu tvXlog_manu) ///
order (tv tvXincome_d1_us tvXunemp_d1_us log_manu tvXlog_manu)

quietly {

	capture log close
  
	log using "`table_name'.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{National- and Local-Level Economic Voting and TV in Presidential Elections}"
	noisily display "\label{`table_label'}"
	noisily display "\begin{tabular}{lcccccc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{6}{c}{Dependent Var = Democratic Vote Share}\\"
	noisily display "\cmidrule(r){2-7}"
	noisily display "&\multicolumn{3}{c}{Per Capita Income (1944--1964)}&\multicolumn{3}{c}{Unemployment (1948--1964)}\\"
	noisily display "\cmidrule(r){2-4} \cmidrule(r){5-7}"
	noisily display "\input{`table_name'_tmp.tex}"
	noisily display "Fixed Effects & County& County& County& County& County& County\\"
    noisily display "& Year& State-Year & Year& Year& State-Year   & Year\\"
	noisily display "County Trends & No& No& Yes& No& No& Yes\\"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item Standard errors, clustered by county, are in parentheses."
	noisily display "County level control variables are included in all columns."
	noisily display "\$\Delta \text{National Income}$, \$\Delta \text{National Unemployment}$, and Log(Manufacturing) are standardized."
	noisily display "\$\Delta \text{National Unemployment}$ is coded such that positive values indicate an improving economy."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}


*********************
** Survey Analysis ** 
*********************

* set up

gen tv=(year>tvyear)
egen time=group(year)

gen log_manu=log(manuval)
local controls  "dem rep male white age_21_34 age_65 married highschool high_income"
local controls2 "pop female urban popsq age21pct sch12 log_manu"

label var tv "TV"

replace pop=pop/1000

label var pop      "Population (Thousand)"
label var female   "Pct. Female"
label var urban    "Pct. Urban"
label var popsq    "Population Per sq. Mile"
label var white    "Pct. White"
label var age21pct "Pct. 21+"
label var sch12    "Pct. 12+ Yrs of Education"
label var log_manu "Log Per Capita Manufacturing Output" 

label var dem         "Democrat"
label var rep         "Republican"
label var male        "Male"
label var white       "White"
label var age_21_34   "Age 21 to 34"
label var age_65      "Age 65+"
label var married     "Married"
label var highschool  "High School Education"
label var high_income "Highest Income Category"

gen tvXecon_dem2 = tv*econ_dem2

label var econ_dem2     "Economic Expectations"
label var tvXecon_dem2  "TV \$\times$ Economic Expectations"


** Table 4 **

eststo clear
eststo: reg econ tv `controls' `controls2' i.year if year == 1952, cluster(fipscode)
eststo: reg v_inc tv econ_dem2 tvXecon_dem2  `controls' `controls2' if year == 1952, cluster(fipscode)

esttab using "table_pocketbook_tmp.tex", ///
	replace label nomtitles fragment booktabs ///
	stats(N, fmt(%7.0fc)) ///
	star(* 0.1 ** 0.05 *** 0.01) nodepvar nonote b(%5.3f) se(%5.3f)  ///
	keep  (tv econ_dem2 tvXecon_dem2) ///
order (tv econ_dem2 tvXecon_dem2)


quietly {

	capture log close
  
	log using "table_pocketbook.tex", text replace

	noisily display "\begin{table}[htbp]"
	noisily display "\centering"
    noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"	
	noisily display "\begin{threeparttable}"
	noisily display "\caption{Television and Pocketbook Consideration}"
	noisily display "\label{table_pocketbook}"
	noisily display "\begin{tabular}{lcc}"
	noisily display "\midrule\midrule"
	noisily display "&\multicolumn{2}{c}{Dep. Var = }\\"
	noisily display "\cmidrule(r){2-3}"  
	noisily display "&\multicolumn{1}{c}{Party}&\multicolumn{1}{c}{Incumbent}\\"
	noisily display "&\multicolumn{1}{c}{Difference}&\multicolumn{1}{c}{Support}\\"
	noisily display "\cmidrule(r){2-2}\cmidrule(r){3-3}"  
	noisily display "\input{table_pocketbook_tmp.tex}"
	noisily display "\midrule\midrule"
	noisily display "\end{tabular}"
	noisily display "\begin{tablenotes}"
	noisily display "\footnotesize"
	noisily display "\item Standard errors, clustered by county, are in parentheses."
	noisily display "County and individual level control variables are included in all column."
	noisily display "\item *** \$p<0.01$; ** \$p<0.05\$; * \$p<0.1\$."
	noisily display "\end{tablenotes}"
	noisily display "\end{threeparttable}"
	noisily display "\end{table}"
  
	log off
  
	log close
}


